package com.Al.pattern.threadLocal;

import sun.security.jca.GetInstance;

/**
 * @Author lizhigang Date: 2019/4/18 10:53
 * @description:threadlocal 单例方式，天然的线程单例，但是主线程存在并发问题
 * 该特性可以做数据源路由
 */
public class ThreadLocalSingleton {
	private ThreadLocalSingleton(){};

	public static final ThreadLocal<ThreadLocalSingleton> THREAD = new ThreadLocal<ThreadLocalSingleton>(){
		@Override
		protected ThreadLocalSingleton initialValue() {
			return new ThreadLocalSingleton();
		}
	};
	public static ThreadLocalSingleton getInstance(){
		return THREAD.get();
	}

}
